﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp15
{
    class Program
    {
        static void Main(string[] args)
        {
            SortedList sortlist = new SortedList();
            sortlist.Add(1, "金庸");
            sortlist.Add(3, "古龙");
            sortlist.Add(2, "黄易");
           
            Console.WriteLine("请输入查找的编号：");
            int id = int.Parse(Console.ReadLine());
            bool flag = sortlist.ContainsKey(id);
            if (flag)
            {
                string name = sortlist[id].ToString();
                Console.WriteLine("该作者为{0}", name);
            }

            else
            {
                Console.WriteLine("您查找的作者不存在");
            }
            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine("所有的作者：");
            foreach (DictionaryEntry v in sortlist)
            {
                int key = (int)v.Key;
                string value = v.Value.ToString();
                Console.WriteLine("编号{0},内容   {1}", key, value);
            }
        }
    }
}
